﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ControlTest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// Initialise the main window
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            syntaxHighlighter.LoadRules(@"TestRules.xml");
            syntaxHighlighter.EnableHighlighting = true;

            DataContext = this;

            TestText = "hello";
        }

        /// <summary>
        /// Databinding test property
        /// </summary>
        public string TestText
        {
            get
            {
                return (string)GetValue(TestTextProperty);
            }
            set
            {
                SetValue(TestTextProperty, value);
            }
        }

        // Using a DependencyProperty as the backing store for TestText.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TestTextProperty =
            DependencyProperty.Register("TestText", typeof(string), typeof(MainWindow), new UIPropertyMetadata(null));

        /// <summary>
        /// Get the data out of the syntax highlighter (tests two way data binding)
        /// </summary>
        /// <param name="sender">Who raised the event</param>
        /// <param name="e">Details about the event</param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(TestText);
        }

        /// <summary>
        /// Toggle Highlighting on and off
        /// </summary>
        /// <param name="sender">Who raised the event</param>
        /// <param name="e">Details about the event</param>
        private void btnToggleHighlight_Click(object sender, RoutedEventArgs e)
        {
            syntaxHighlighter.EnableHighlighting = !syntaxHighlighter.EnableHighlighting;
        }

    }
}
